package HuaweiOD;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;

public class 找到字符串中所有字母异位词 {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        String s = in.nextLine(), p = in.nextLine();
        findAnagrams(s, p).stream().map(id -> id + " ").forEach(System.out::println);
    }

    public static List<Integer> findAnagrams(String s, String p) {
        int lens = s.length();
        int lenp = p.length();
        
        if (lens < lenp){
            return new ArrayList<>();
        }
        
        int[] sCount = new int[26];
        int[] pCount = new int[26];
        for (int i = 0; i < lenp; i++) {
            ++sCount[s.charAt(i) - 'a'];
            ++pCount[p.charAt(i) - 'a'];
        }
        
        ArrayList<Integer> ans = new ArrayList<>();
        if (Arrays.equals(pCount,sCount)){
            ans.add(0);
        }

        for (int i = 0; i < lens - lenp; i++) {
            --sCount[s.charAt(i) - 'a'];
            ++sCount[s.charAt(i + lenp) - 'a'];
            if (Arrays.equals(pCount, sCount)){
                ans.add(i + 1);
            }
        }
        
        return ans;
    }
}
